<%@ include file="../../common/tag.jsp"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<html>
<head>
<title>LiNing | Login</title>
<link href="${ctx }/css/bootstrap.min14ed.css?v=3.3.6" rel="stylesheet">
<link href="${ctx }/font-awesome/css/font-awesome.css" rel="stylesheet">
<link href="${ctx }/css/animate.css" rel="stylesheet">
<link href="${ctx }/css/style.min862f.css?v=4.1.0" rel="stylesheet">
<style type="text/css">
.background{
 background-image: url("${ctx }/img/background.png");
}
</style>
</head>
<body class="gray-bg background">
	<div class="middle-box text-center loginscreen animated fadeInDown">
		
			<div>
				<h1 class="logo-name"><img src="${ctx }/img/logo.png" style="width:100%;" /></h1>
			</div>
			<div  style="background-color:white;padding:20px;border-radius:6px">
				<h3><img src="${ctx }/img/liningguanli.png" style="width:80%;" /></h3>
				<form class="m-t" id="formlogin" role="form" method="post" action="" onsubmit="return false;" onkeydown="on_return();">
					<div class="form-group">
						<input type="text" id="loginname" name="userName" class="form-control" placeholder="登录名"
							required="1111">
					</div>
					<div class="form-group">
						<input type="password" id="nloginpwd" name="userPwd" class="form-control" placeholder="密	码"
							required="">
							<label id="loginpwd_succeed" class="blank invisible" style="color: red"></label>
					</div>
					<button type="button" id="loginsubmit" class="btn btn-danger block full-width m-b">登	录</button>
	
					
				</form>
			</div>
		</div>
	</div>

</body>
<script src="${ctx }/js/jquery.min.js?v=2.1.4"></script>
<script type="text/javascript">
var redirectUrl = "${redirect}";
var LOGIN = {
		checkInput:function() {
			if ($("#loginname").val() == "") {
				$("#loginpwd_succeed").html("用户名不能为空");
				$("#loginname").focus();
				return false;
			}
			if ($("#nloginpwd").val() == "") {
				$("#loginpwd_succeed").html("密码不能为空");
				$("#nloginpwd").focus();
				return false;
			}
			return true;
		},
		doLogin:function() {
			$.post("${ctx }/user/doLogin", $("#formlogin").serialize(),function(data){
				if (data.errorCode == 0) {
					if (redirectUrl == "") {
						location.href = "${ctx }/user";
					} else {
						location.href ="${ctx }/user?redirectUrl="+redirectUrl;
					}
				} else {
					alert("登录失败，原因是：" + data.errorMsg);
					$("#loginname").select();
				}
			});
		},
		login:function() {
			if (this.checkInput()) {
				this.doLogin();
			}
		}
	
};
$(function(){
	$("#loginsubmit").click(function(){
		LOGIN.login();
	});
});
function on_return(){
 if(window.event.keyCode == 13){
  LOGIN.login();
 }
 }
</script>
</html>